public class Main {
    /**
     * 寻找峰值
     * @param args
     */
    public static void main(String[] args) {
        int[] arr={2,4,1,2,7,8,4};
        System.out.println(findPeakElement(arr));
    }
    public static int findPeakElement (int[] nums) {
        int left=0;
        int right=nums.length-1;
        while(left<right){
            int mid=(left+right)/2;
            if(nums[mid]<nums[mid+1]){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return left;
    }
}